package com.qk.management.controller;

import com.qk.common.Result;
import com.qk.entity.Activity;
import com.qk.management.service.ActivityService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*
 *  @author SHCJ
 *  @created 2025/10/7 20:13
 *  @description
 */
@RestController
@RequestMapping("/activities")
public class ActivityController {
    @Autowired
    private ActivityService activeService;

//    分页查询
    @GetMapping
    public Result page( Integer channel,Integer type,Integer status,  Integer page, Integer pageSize){

        return Result.success(activeService.page(channel,type,status,page,pageSize));
    }

//    删除活动
    @DeleteMapping("{id}")
    public Result delete(@PathVariable Integer id){
        activeService.delete(id);
        return Result.success();
    }

//    新增活动
    @PostMapping
    public Result add(@RequestBody Activity activity){
        activeService.add(activity);
        return Result.success();
    }

//    根据id查询
    @GetMapping("{id}")
    public Result findById(@PathVariable Integer id){
        return Result.success(activeService.findById(id));
    }

//    修改活动
    @PutMapping
    public Result update(@RequestBody Activity activity){
        activeService.update(activity);
        return Result.success();
    }

//    查询指定类型活动
    @GetMapping("/type/{channel}")
    public Result findByType(@PathVariable Integer channel){
        return Result.success(activeService.findByType(channel));
    }
}
